package com.qf.xiaomi.web.servlet.admin;

import com.qf.xiaomi.pojo.TbGoods;
import com.qf.xiaomi.pojo.TbUser;
import com.qf.xiaomi.service.GoodsService;
import com.qf.xiaomi.service.impl.GoodsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * Created by 田贵宾 on 2022/8/21 19:14
 *
 * @author 田贵宾
 * @version 1.0
 * //TODO java练习阶段
 * @since 1.0
 */
@WebServlet("/getGoodsList")
public class GoodsListServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        GoodsService service = new GoodsServiceImpl();
        List<TbGoods> goods = service.findGoods();
        req.setAttribute("goodsList",goods);
        req.getRequestDispatcher("/admin/showGoods.jsp").forward(req,resp);
    }
}
